package com.ruoyi.web.controller.fx;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.fx.FxPageSet;
import com.ruoyi.system.service.fx.IFxPageSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 首页页面设置Controller
 *
 * @author ruoyi
 * @date 2025-05-06
 */
@RestController
@RequestMapping("/system/pageSet")
public class FxPageSetController extends BaseController
{
    @Autowired
    private IFxPageSetService fxPageSetService;

    /**
     * 查询首页页面设置列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FxPageSet fxPageSet)
    {
        startPage();
        List<FxPageSet> list = fxPageSetService.selectFxPageSetList(fxPageSet);
        return getDataTable(list);
    }

    /**
     * 导出首页页面设置列表
     */
    @Log(title = "首页页面设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FxPageSet fxPageSet)
    {
        List<FxPageSet> list = fxPageSetService.selectFxPageSetList(fxPageSet);
        ExcelUtil<FxPageSet> util = new ExcelUtil<FxPageSet>(FxPageSet.class);
        util.exportExcel(response, list, "首页页面设置数据");
    }

    /**
     * 获取首页页面设置详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fxPageSetService.selectFxPageSetById(id));
    }

    /**
     * 新增首页页面设置
     */
    @Log(title = "首页页面设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FxPageSet fxPageSet)
    {
        return toAjax(fxPageSetService.insertFxPageSet(fxPageSet));
    }

    /**
     * 修改首页页面设置
     */
    @Log(title = "首页页面设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FxPageSet fxPageSet)
    {
        return toAjax(fxPageSetService.updateFxPageSet(fxPageSet));
    }

    /**
     * 删除首页页面设置
     */
    @Log(title = "首页页面设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fxPageSetService.deleteFxPageSetByIds(ids));
    }
}
